package ch.sv7.tool.dbmanager.db.fix;

import ch.sv7.tool.dbmanager.db.ForeignKeySchema;
import ch.sv7.tool.dbmanager.db.SchemaElement;
import ch.sv7.tool.dbmanager.db.dialect.DialectException;

/**
 * TODO: Document me!
 *
 * @author svt
 *
 */
public class DropForeignKeyFix extends AbstractSchemaFix implements SchemaFix {

	private ForeignKeySchema fkSchema;

	/**
	 * @param missingIndexDifference
	 */
	public DropForeignKeyFix(ForeignKeySchema fkSchema) {
		super();
		this.fkSchema = fkSchema;
	}

	public SchemaElement getActionTarget() {
		return fkSchema;
	}
	
	public String getSQLFix() throws DialectException {
		String ddl = "\n-- Drop ForeignKey Fix \n";
		ddl += getDialect().getDropForeignKeyDDL(fkSchema);
		return ddl;
	}

	public int getPriority() {
		return SchemaFix.PRIORITY_FOREIGN_KEY_DROP;
	}

	public String getDescription() {
		return "Drop foreign key " + fkSchema.getTableSchema().getName()+"."+fkSchema.getName();
	}

	public int getAction() {
		return ACTION_DROP;
	}

}
